﻿using System;
using UnityEngine;

[RequireComponent(typeof(Camera)), ExecuteInEditMode]
public class CameraDownSample : MonoBehaviour
{
    [Range(0f, 8f)]
    public int downSample = 1;

    private void OnRenderImage(RenderTexture src, RenderTexture dest)
    {
        RenderTexture temporary = RenderTexture.GetTemporary(Screen.width >> this.downSample, Screen.height >> this.downSample);
        temporary.filterMode = FilterMode.Point;
        Graphics.Blit(src, temporary);
        Graphics.Blit(temporary, dest);
        RenderTexture.ReleaseTemporary(temporary);
    }
}

